﻿using System.Collections.Generic;
using System.Web.Http;
using DefaultConnection;
using MementoWeb.Models;

namespace MementoWeb.Controllers
{
    public class WorkCategoryController : ApiController
    {
        private readonly IDataRepository _dataRepository; 

        public WorkCategoryController(IDataRepository dataRepository)
        {
            _dataRepository = dataRepository;
        }

        public IEnumerable<WorkCategory> Get()
        {
            return _dataRepository.GetAllWorkCategories();
        }

        public WorkCategory GetById( int id )
        {
            return _dataRepository.GetWorkCategoryById(id);
        }

        public void CreateNew( WorkCategory workCategory )
        {
            _dataRepository.CreateNewWorkCategory(workCategory);
        }

        public void Update( WorkCategory workCategory )
        {
            _dataRepository.SaveWorkCategoryChanges(workCategory);
        }

        public void Delete( int id )
        {
            _dataRepository.DeleteWorkCategory(id);
        }
    }
}
